package collection;

/**
 * @Description:
 * @Author 左龙龙
 * @Date 21-3-11
 * @Version 1.0
 **/
public class Person{
    String id;
    String name;

    public Person(String id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        System.out.println(id + ", call equals");

        if(obj instanceof Person){
            Person p = (Person) obj;

            return id != null && id.equals(p.id);
        }

        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        System.out.println(id + ", call hashCode");

        return id.hashCode();
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}